﻿<script src="~/Scripts/jquery-easyui-extensions/portal/jquery.portal.original.js"></script>
<style>
    .changeLog {
    }

        .changeLog li {
            padding: 5px;
        }

    .donateList {
        list-style:none;
    }

        .donateList li {
        }

    .donate-name {
        font-weight: bold;
        line-height: 14px;
        background-color: rgb(70, 136, 71);
        color: #fff;
        padding-top: 2px;
        padding-bottom: 2px;
        padding-left: 4px;
        padding-right: 4px;
        border-radius: 3px;
    }

    .donate-date {
        padding: 5px;
    }

    .donate-total {
        font-weight: bold;
        color: Red;
    }
</style>
<div id="deskLayout" class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',border:false" style="height: 60px; font-size: 16px; font-weight: bold; padding: 20px 10px; background: #eee; overflow: hidden; border-bottom-width: 1px; ">
        Easyui扩展整理库。
        扩展整理原则：低耦合。
        扩展来源：前辈高人已完成的扩展（宇神、夏悸、流云、IT工头）、我自己写的扩展。
    </div>
    <div id="portalContainer" data-options="region:'center',border:false,title:'当前 Easyui 版本：1.4.3'">
        <div id="portal" class="easyui-portal" data-options="fit:true,border:false">
            <div style="width:60%;">
                <div title="更新日志" style="height:350px;padding:5px;">
                    <ul id="ulChangeLog" class="changeLog"></ul>
                </div>
            </div>
            <div style="width:40%;">
                <div title="开源" style="height: 350px; padding: 5px;">
                    <a id="btnAlipay" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-alipay'">若有所收获，可以点击支付宝捐赠我。</a>
                    <div id="divAlipay" style="width:175px;height:15px;"></div>
                    <ul id="ulDonateLog" class="donateList">
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

    window.deskIndex = {};
    window.deskIndex.resizePortal = function (resizeFull) {
        var port = $("#portal"), portalHeight = port.height(), internalPadding = 10, containerHeight = $("#portalContainer").height(),
                panels = port.portal("getPanels");
        //console.log("容器高度：" + containerHeight); console.log("portal高度：" + portalHeight);
        //console.log("panel原高度：" + panels[0].panel("options").height);
        $.array.forEach(panels, function (item) {
            item.panel("options").height = containerHeight - (2 * internalPadding) - 13;
        });
        if (portalHeight < containerHeight) {
            var newSize = { height: containerHeight };
            port.portal("resize", newSize);
        } else {
            port.portal("resize");
        }
        //console.log("panel新高度：" + panels[0].panel("options").height);
        if (resizeFull) {
            
        }
    };

    $(function () {
        var changeLogsUl = $("#ulChangeLog");
        $.getJSON("/Common/changeLogs-data.json", function (json) {
            json.forEach(function (item) {
                $("<li />").html("[ " + item.Date + " ] <b>" + item.Log + "</b>").appendTo(changeLogsUl);
            });

        });

        var donateLogsUl = $("#ulDonateLog");
        $.getJSON("/Common/donate-data.json", function (json) {
            json.forEach(function (item) {
                $("<li />").html("<span class=\"donate-name\">" + item.RealName + " " + item.Email + "</span><span class=\"donate-date\">" + item.Date + "</span><span>(</span><span class=\"donate-total\">" + item.Total + "</span><span>元)</span>").appendTo(donateLogsUl);
                $("<br />").appendTo(donateLogsUl);
            });
        });

        var showAlipay = function () {
            var t = $("#divAlipay"),
                opts = {
                    position: "right",
                    content: "<img src=\"/Content/images/alipay.png\" title=\"感谢你支持我\" />"
                };
            $("#btnAlipay").click(function () {
                t.tooltip($.extend({ trackMouse: false }, opts, {
                    onHide: function () {
                        if ($.isFunction(opts.onHide)) { opts.onHide.apply(this, arguments); }
                        t.tooltip("destroy");
                    }
                })).tooltip("show");
            });
        };

        showAlipay();

        setTimeout(window.deskIndex.resizePortal, 500);
    });
</script>